<style>
    #body{
        padding-top: 0 !important;
    }
</style>

<?php
    $x = new Zend_Auth_Storage_Session('User_Auth');
    $y = $x->read();

    $alldata = $this->alldata;
//    prd($alldata);
    $event_id = $alldata["event_id"];
    $event_images = getEventImages($alldata["event_id"]);
    $event_full_address = $alldata["event_address"] . ", " . $alldata["event_location"];
    $map_event_address = str_replace(" ", "+", $event_full_address);
?>

<div id="body" class="layout">
    <div class="wrap">
        <div class="left">
            <ul class="sort-panel">
                <li class="s-text">Search events:</li>
                <li>
                    <a href="<?php echo $this->baseUrl(''); ?>">
                        <span class="first">
                            <span class="last">
                                <span class="middle">
                                    Home
                                </span>
                            </span>
                        </span>
                    </a>
                </li>
                <li>
                    <a href="<?php echo $this->baseUrl("eventdetail/" . getEncryptedString($alldata["event_id"])); ?>" class="current selected">
                        <span class="first">
                            <span class="last">
                                <span class="middle">
                                    <?php echo stripslashes($alldata["event_title"]); ?>
                                </span>
                            </span>
                        </span>
                    </a>
                </li>
            </ul>
            <div class="cf"></div>
            <div class="slider">
                <a href="#" id="toPlayVideo">
                    <img class="main-img fl" alt="<?php echo stripslashes($alldata["event_title"]); ?>" src="<?php echo $event_images[0]; ?>" />
                </a>
                <div class="thumbs fl">
                    <ul>
                        <?php
//                            for ($i = "0"; $i <= "3"; $i++)
                            for ($i = "0"; $i <= "2"; $i++)
                            {
                                if (isset($event_images[$i]))
                                {
                                    $image_url = $event_images[$i];
                                    echo '<li><a href="' . $image_url . '" class="bannerImg" rel="image"><img src="' . $image_url . '" alt="' . stripslashes($alldata["event_title"]) . "-" . $i . '" /></a></li>';
                                }
                            }

                            $event_video = $alldata["event_video"];
                            if (!empty($event_video))
                            {
                                $video_detail = getVideoServiceName($event_video);
                                $video_id = $video_detail["video_id"];
                                $video_service = $video_detail["video_service"];
                                $video_thumb = getVideoThumb($video_id, $video_service);
                                $video_embed_url = getVideoEmbedUrl($video_id, $video_service);

                                echo '<li><a href="' . $video_embed_url . '" class="bannerImg" rel="video"><img src="' . $video_thumb . '" alt="video" title="Video"/></a></li>';
                            }
                        ?>
                    </ul>
                </div>
                <div class="cf"></div>
            </div>
            <div class="post-content">
                <div class="social-share">
                    <?php
                        if (!empty($y) && $alldata["event_created_by"] != $x->read()->user_id)
                        {
                            ?>
                            <div class="ssleft fl">
                                <?php
                                if ($this->isBookmarked == "no")
                                    echo '<a href="#pmsg" class="bookmark">Bookmark</a>';
                                else
                                    echo '<a href="#pmsg" class="uncheck">Uncheck</a>';
                                ?>
                            </div>
                            <?php
                        }
                    ?>
                    <div class="ssright fr">
                        <span class="fb-sb">
                            <?php
                                $share_url = (SITE_HTTP_URL . "/eventdetail/" . getEncryptedString($event_id));
                            ?>
                            <!--<span class="sb" onclick="javascript:void(window.open('https://www.facebook.com/sharer/sharer.php?u=<?php echo $share_url; ?>', 'sharer', 'width=626,height=436,toolbar=0,status=0'));"></span>-->
                            <!--<span class="sc">158</span>-->
                        </span>
                        &nbsp;<a href="<?php echo getShareWithFacebook($share_url); ?>" target="_blank"><img src="<?php echo IMAGES_PATH; ?>/fs-bg.png" alt="facebook" /></a>
                        &nbsp;<a href="<?php echo getShareWithTwitter("Check this out " . $share_url); ?>" target="_blank"><img src="<?php echo IMAGES_PATH; ?>/bg-twitter.png" alt="twitter" /></a>
                        <a href="<?php echo getShareWithLinkedin($share_url, stripslashes($alldata["event_title"]), stripslashes($alldata["event_info"])); ?>" target="_blank"><img src="<?php echo IMAGES_PATH; ?>/bg-linked.png" alt="twitter" /></a>
                    </div>
                    <div class="cf"></div>
                </div>
                <h1 class="post-title">
                    <?php echo stripcslashes($alldata["event_title"]); ?>
                </h1>
                <div class="publish">
                    <?php echo ucwords($alldata["event_type"]); ?>
                </div>
                <div class="content-wrap">
                    <div class="infos">
                        <div class="fl infoleft">
                            <p>Posted in: <span class="org"><?php echo $alldata["category_name"] . ", " . $alldata["subcategory_name"]; ?></span></p>
                            <?php
                                $event_date_array = json_decode($alldata["event_date"]);
                                $event_date = $event_date_array->day[0] . " " . date("F", strtotime($event_date_array->month[0])) . " " . $event_date_array->year[0];
                            ?>
                            <p>Date: <span class="org"><?php echo $event_date; ?></span></p>
                            <!--<p>Time: <span class="org"><?php echo date("H:i", strtotime($alldata["event_time"])) . " " . TIME_ZONE; ?></span></p>-->

                            <?php
                                if ($this->isUsersOwnEvent == "no")
                                {
                                    if ($alldata["event_type"] == "private" && $this->eventJoinStatus == "0")
                                    {
                                        echo '<p>Time: <span class="org">Displayed when you join</span></p>';
                                    }
                                    else
                                    {
                                        ?>
                                        <p>Time: <span class="org"><?php echo date("g:i a", strtotime($alldata["event_time"])); ?></span></p>
                                        <?php
                                    }
                                }
                                else
                                {
                                    ?>
                                    <p>Time: <span class="org"><?php echo date("g:i a", strtotime($alldata["event_time"])); ?></span></p>
                                    <?php
                                }
                            ?>
                            <p>Address: <span class="org"><?php echo $alldata["event_address"] . ", " . $alldata["event_location"]; ?></span></p>
                            <?php
//                                if ($this->isUsersOwnEvent == 'no')
//                                {
//                                    if ($alldata["event_type"] == "private" && $this->isJoined == "no")
//                                    {
//                                        
                            ?>
                                        <!--<p>Address: <span class="org"><?php echo $alldata["event_location"]; ?></span></p>-->
                            <?php
//                                    }
//                                    else
//                                    {
//                                        
                            ?>
                            <!--<p>Address: <span class="org">//<?php echo $alldata["event_address"] . ", <br>" . $alldata["event_location"]; ?></span></p>-->
                            <?php
//                                    }
//                                }
//                                else
//                                {
//                                    
                            ?>
                        <!--<p>Address: <span class="org">//<?php echo $alldata["event_address"] . ", " . $alldata["event_location"]; ?></span></p>-->
                            <?php
//                                }
                            ?>
                        </div>
                        <div class="fr inforight">
                            <p class="ralign">Group size: <span class="b"><?php echo $alldata["event_group_type"] == 'unlimited' ? "Unlimited" : $alldata["event_group_size"] . " spots"; ?></span> </p>
                            <?php
                                if ($alldata["event_group_type"] == "limited")
                                {
                                    ?>
                                    <p class="ralign"><span class="org"><?php echo $this->availableSpots; ?> Available</span></p>
                                    <?php
                                }
                            ?>
                            <?php
                                if ($this->isUsersOwnEvent == 'no')
                                {

                                    if (!empty($y))
                                    {
                                        if ($this->isJoined == "no")
                                        {
                                            if (($this->availableSpots != "0" || !empty($this->availableSpots) ) || $alldata['event_group_type'] == "unlimited")
                                            {
                                                ?>
                                                <div class="request-login gray-first">
                                                    <div class="gray-middle">
                                                        <div class="fl">Join event</div>
                                                        <a id="leave-button" class="rbox bluebutton2 fr" href="#join-msg"><strong>Send</strong></a>
                                                    </div>
                                                </div>

                                                <div class="alert-message" id="join-msg">
                                                    <div class="am-wrapper">
                                                        <a href="#close" class="close-button"></a>
                                                        <div class="title">
                                                            Alert <strong>Message</strong>
                                                        </div>
                                                        <div class="content">
                                                            Are you <strong>SURE</strong> you want to join this Event?
                                                        </div>
                                                        <div class="buttons">
                                                            <a href="#" class="bluefbutton fl close-cancel">Cancel</a>
                                                            <a href="#" class="yefbutton fl" id="event-join">Join</a>
                                                            <div class="cf"></div>
                                                        </div>
                                                    </div>
                                                </div>
                                                <?php
                                            }
                                        }
                                        else
                                        {
                                            if ($this->eventJoinStatus == "1")
                                            {
                                                ?>
                                                <div class="attending gray-first">
                                                    <div class="gray-middle">
                                                        <div class="fl">You are attending<br/> this Event.</div>
                                                        <a id="leave-button" class="rbox orgbutton fr" href="#leave-msg"><strong>Leave</strong></a>
                                                    </div>
                                                </div>

                                                <div class="alert-message" id="leave-msg">
                                                    <div class="am-wrapper">
                                                        <a href="#close" class="close-button"></a>
                                                        <div class="title">
                                                            Alert <strong>Message</strong>
                                                        </div>
                                                        <div class="content">
                                                            Are you <strong>SURE</strong> you want to leave this Event?
                                                        </div>
                                                        <div class="buttons">
                                                            <a href="#" class="bluefbutton fl">Cancel</a>
                                                            <a href="#" class="yefbutton fl" id="event-leave">Leave</a>
                                                            <div class="cf"></div>
                                                        </div>
                                                    </div>
                                                </div>
                                                <?php
                                            }
                                            else
                                            {
                                                ?>
                                                <div class="attending gray-first">
                                                    <div class="gray-middle">
                                                        <div class="fl">Awaiting approval<br/> for this Event.</div>
                                                        <a id="leave-button" class="rbox orgbutton fr" href="#leave-msg"><strong>Leave</strong></a>
                                                    </div>
                                                </div>

                                                <div class="alert-message" id="leave-msg">
                                                    <div class="am-wrapper">
                                                        <a href="#close" class="close-button"></a>
                                                        <div class="title">
                                                            Alert <strong>Message</strong>
                                                        </div>
                                                        <div class="content">
                                                            Are you <strong>SURE</strong> you want to leave this Event?
                                                        </div>
                                                        <div class="buttons">
                                                            <a href="#" class="bluefbutton fl">Cancel</a>
                                                            <a href="#" class="yefbutton fl" id="event-leave">Leave</a>
                                                            <div class="cf"></div>
                                                        </div>
                                                    </div>
                                                </div>
                                                <?php
                                            }
                                        }
                                    }
                                    else
                                    {
                                        ?>
                                        <div class="request-login gray-first">
                                            <div class="gray-middle">
                                                <div class="fl">Join event</div>
                                                <a id="not-loggedin-popup" class="rbox bluebutton2 fr"><strong>Send</strong></a>
                                            </div>
                                        </div>

                                        <script>
                                            $(document).ready(function() {
                                                $("#not-loggedin-popup").click(function() {
                                                    $('#login-button').click();
                                                });
                                            });
                                        </script>
                                        <?php
                                    }
                                }
                            ?>
                        </div>
                        <div class="cf"></div>
                    </div>
                    <div class="details">
                        <h3><strong>Event Info:</strong></h3>
                        <div><?php echo stripslashes(getStringTheWayItIs($alldata["event_info"])); ?></div>
                    </div>
                    <div class="cf"></div>

                    <?php
                        if ($this->isUsersOwnEvent == "no")
                        {
                            ?>

                            <div class="friends">
                                <div class="friend-wrap" style="background-position: 82px;">
                                    <div class="fl host">
                                        <p class="org">Host:</p>
                                        <div class="avt">
                                            <div class="blu"><strong><?php echo $alldata["user_first_name"] . " " . $alldata["user_last_name"]; ?></strong></div>
                                            <div><a class="fl pprofile" href="#host-profile"><span class="bg"></span><img src="<?php echo getUserImage($alldata["user_id"]); ?>" alt="<?php echo $alldata["user_first_name"] . " " . $alldata["user_last_name"]; ?>" /></a></div>
                                        </div>
                                    </div>
                                    <div class="fl fr-list" style="padding-left: 30px;">
                                        <p class="org">Attending:</p>
                                        <ul>
                                            <?php
                                            if (!empty($this->usersAttending))
                                            {
                                                foreach ($this->usersAttending as $u_key => $u_value)
                                                {
                                                    $user_id = $u_value["user_id"];
                                                    $user_full_name = $u_value["user_first_name"] . " " . $u_value["user_last_name"];
                                                    ?>
                                                    <li>
                                                        <a class="tips show-profile-test" tips="<?php echo $user_full_name; ?>" href="#show-profile-<?php echo $user_id; ?>">
                                                            <span class="bg"></span>
                                                            <img alt="<?php echo $user_full_name; ?>" src="<?php echo getUserImage($user_id); ?>">
                                                        </a>
                                                    </li>
                                                    <?php
                                                }
                                            }
                                            ?>
                                        </ul>
                                        <div class="cf"></div>
                                        <a class="rarrow" href="#"><img src="<?php echo IMAGES_PATH; ?>/white-arrow.png" alt="arrow" /></a>
                                    </div>
                                    <div class="cf"></div>
                                </div>
                            </div>
                            <div class="maps">
                                <div class="mleft fl">
                                    <p>The <span class="blu"><?php echo stripslashes($alldata["event_title"]); ?></span> will be held </p>
                                    <?php
                                    if ($alldata["event_type"] == "private" && $this->isJoined == "no")
                                    {
                                        ?>
                                        <p>at <span class="org"><?php echo $alldata["event_location"]; ?></span>,</p>
                                        <?php
                                    }
                                    else
                                    {
                                        ?>
                                        <p>at <span class="org"><?php echo $alldata["event_address"] . ", " . $alldata["event_location"]; ?></span>,</p>
                                        <?php
                                    }
                                    $event_date_array = json_decode($alldata["event_date"]);
                                    $event_date = $event_date_array->day[0] . " " . date("F", strtotime($event_date_array->month[0])) . " " . $event_date_array->year[0];
                                    ?>
                                    <p>on <span class="org"><?php echo $event_date; ?>,</span></p>
                                    <!--<p>at <span class="org"><?php echo date("H:i", strtotime($alldata["event_time"])) . " " . TIME_ZONE; ?></span></p>-->
                                    <!--<p>at <span class="org"><?php echo date("g:i a", strtotime($alldata["event_time"])); ?></span></p>-->

                                    <?php
                                    if ($alldata["event_type"] == "private" && $this->isJoined == "no")
                                    {
                                        echo '<p>at <span class="org">Displayed when you join</span></p>';
                                    }
                                    else
                                    {
                                        ?>
                                        <p>at <span class="org"><?php echo date("g:i a", strtotime($alldata["event_time"])); ?></span></p>
                                        <?php
                                    }
                                    ?>

                                </div>
                                <div class="mright fr">
                                    <p>Type in ZIP code or City </p>
                                    <p>to see distance in miles away. </p>
                                    <div style="display: inline-block;">
                                        <input type="text" class="fl location" id="another_address" placeholder="New York" />&nbsp;&nbsp;<a class="rbox yebutton2 fr" id="check-distance" href="#">Check</a>
                                    </div>
                                    <div><p style="padding: 0 5px;" id="distance-here"></p></div>
                                </div>
                                <div class="cf"></div>
                                <div class="gmap">
                                    <iframe width="528" height="218" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps?q=<?php echo $map_event_address; ?>&amp;output=embed"></iframe><br /><small><a href="https://maps.google.com/maps?f=q&amp;source=embed&amp;hl=en&amp;geocode=&amp;q=pratap+nagar+,+jodhpur&amp;aq=&amp;sll=37.0625,-95.677068&amp;sspn=40.188298,86.572266&amp;ie=UTF8&amp;hq=&amp;hnear=Pratap+Nagar,+Jodhpur,+Rajasthan,+India&amp;t=m&amp;z=14&amp;ll=26.283191,73.000677" style="color:#0000FF;text-align:left"></a></small>
                                </div>
                            </div>

                            <?php
                        } //end of condition where event will be shown to all other users
                        else
                        {
                            ?>
                            <div class="friends">
                                <div class="friend-wrap own-event">
                                    <div class="fleft fl">
                                        <p class="org"><a href="#attending-list" class="attending-list">Attending:</a></p>
                                        <ul>
                                            <!--                                            <li>
                                                                                            <a class="tips" tips="Jane Doe" href="#"><span class="bg" style="opacity: 0; display: block;"></span><span class="icon del" style="opacity: 0; display: block;"></span><img alt="thumb" src="images/thumb9.jpg"></a>
                                                                                        </li>-->
                                            <?php
                                            if (!empty($this->usersAttending))
                                            {
                                                foreach ($this->usersAttending as $u_key => $u_value)
                                                {
                                                    $user_id = $u_value["user_id"];
                                                    $user_full_name = $u_value["user_first_name"] . " " . $u_value["user_last_name"];
                                                    ?>
                                                    <li id="member-<?php echo $u_value['user_id'] ?>">
                                                        <a class="tips show-profile-test" tips="<?php echo $user_full_name; ?>" href="#show-profile-<?php echo $user_id; ?>">
                                                            <span class="bg"></span>
                                                            <span class="icon del" onclick="ConfirmRemoveEventMember('Confirm Box', 'Are you sure you want to remove <?php echo $user_full_name; ?>?', '<?php echo $this->baseUrl("ajax/deleteeventmember/ej_id/" . $u_value['ej_id'] . "/"); ?>', 'member-<?php echo $u_value['user_id'] ?>');
                                                    if (event.stopPropagation) {
                                                        event.stopPropagation();
                                                    }
                                                    event.cancelBubble = true;
                                                    return false;"></span>
                                                            <img alt="<?php echo $user_full_name; ?>" src="<?php echo getUserImage($user_id); ?>">
                                                        </a>
                                                    </li>
                                                    <?php
                                                }
                                            }
                                            ?>
                                        </ul>
                                        <div class="cf"></div>
                                    </div>
                                    <div class="fright fl">
                                        <p class="blu">Waiting list:</p>
                                        <ul>
                                            <?php
                                            if (!empty($this->usersWaiting))
                                            {
                                                foreach ($this->usersWaiting as $u_key => $u_value)
                                                {

                                                    $user_id = $u_value["user_id"];
                                                    $user_full_name = $u_value["user_first_name"] . " " . $u_value["user_last_name"];
                                                    ?>
                                                    <li id="member-<?php echo $u_value['user_id'] ?>">
                                                        <a class="tips show-profile-test" tips="<?php echo $user_full_name; ?>" href="#show-profile-<?php echo $user_id; ?>">
                                                            <span class="bg"></span>
                                                            <span class="icon add" onclick="ConfirmAddEventMember('Confirm Box', 'Are you sure you want to add?', '<?php echo $this->baseUrl("ajax/eventjoin/approve/true/user_id/" . $u_value['user_id'] . "/event_id/" . $this->event_id . "/"); ?>', 'member-<?php echo $u_value['user_id'] ?>');
                                                    if (event.stopPropagation) {
                                                        event.stopPropagation();
                                                    }
                                                    event.cancelBubble = true;
                                                    return false;"></span>
                                                            <img alt="<?php echo $user_full_name; ?>" src="<?php echo getUserImage($user_id); ?>">
                                                        </a>
                                                    </li>
                                                    <?php
                                                }
                                            }
                                            ?>
                                        </ul>
                                        <div class="cf"></div>
                                    </div>
                                    <div class="cf"></div>
                                    <div class="arr-blue"><a href="#"><img alt="arrow" src="<?php echo IMAGES_URL; ?>blue-arrow.png"></a></div>
                                </div>
                            </div>

                            <div id="attending-list"  class="alert-message show-profile">
                                <div class="am-wrapper">
                                    <a href="#close" class="close-button"></a>
                                    <div class="title" style="text-align:center;">
                                        <strong><?php echo stripslashes($this->alldata['event_title']); ?></strong>
                                        <ul>
                                            <li>
                                                <span class="head">Date</span>
                                                <span class="body"><?php echo $event_date; ?></span>
                                            </li>
                                            <li>&nbsp;</li>
                                            <li>
                                                <span class="head">Time</span>
                                                <span class="body"><?php echo date("H:i", strtotime($alldata["event_time"])) . " " . TIME_ZONE; ?></span>
                                            </li>
                                            <li>&nbsp;</li>
                                            <li>
                                                <span class="head">Address</span>
                                                <span class="body"><?php echo $alldata["event_address"] . ", " . $alldata["event_location"]; ?></span>
                                            </li>

                                        </ul>
                                    </div>
                                    <div class="ginfos">
                                        <table cellpadding="0" cellspacing="0" style="width:100%;margin-bottom:20px;">
                                            <thead>
                                                <tr>
                                                    <td>#</td>

                                                    <td>Attendees</td>

                                                    <td>Date</td>

                                                    <td>Unknown column</td>

                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php
                                                if (count($this->usersAttending) > 0):
                                                    foreach ($this->usersAttending as $uKey => $uVal)
                                                    {
                                                        ?>
                                                        <tr class="attending-list">
                                                            <td><?php echo $uKey + 1; ?></td>
                                                            <td>
                                                                <table cellpadding="0" cellspacing="0" border="0" class="user_details">
                                                                    <tr>
                                                                        <td><img src="<?php echo getUserImage($alldata["user_id"]); ?>" ></td>
                                                                        <td><strong><?php echo $alldata["user_first_name"] . " " . $alldata["user_last_name"]; ?></strong><br>
                                                                            <span class="blu"><?php echo $alldata["user_email"]; ?></span>
                                                                        </td>
                                                                    </tr>
                                                                </table>
                                                                <div class="left_side"></div>
                                                                <div class="right_side"></div>
                                                            </td>
                                                            <td></td>
                                                            <td></td>
                                                        </tr>
                                                        <?php
                                                    }
                                                else:
                                                    echo "<tr><td colspan='4' style='text-align:center;padding:10px;'>No attendees found</td></tr>";
                                                endif;
                                                ?>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>

                        <?php }
                    ?>

                </div>
            </div>
        </div>
        <div class="right">
            <div class="rtitle">
                Chat Box
            </div>
            <div class="box chat-box">
                <ul id="chat-wrapper" >
                    <?php
                        $last_chat_id = "";
                        //prd($this->chatRecords);
                        if (!empty($this->chatRecords))
                        {
                            $chat_count = count($this->chatRecords);
                            $last_chat_id = $this->chatRecords[$chat_count - 1]["ec_id"];
                            $chatUserArr = array();
                            foreach ($this->chatRecords as $c_key => $c_value)
                            {
                                $full_name = $c_value["user_first_name"] . " " . $c_value["user_last_name"];
                                $message = $c_value["ec_message"];
                                $time_ago = getTimeAgo(strtotime($c_value["ec_timestamp"]));
                                //if(!in_array($c_value['user_id'],$chatUserArr))
                                $chatUserArr[] = $c_value['user_id'];
                                ?>
                                <li>
                                    <a href="#show-profile-<?php echo $c_value['user_id'] ?>" class="show-profile-test">
                                        <img class="fl" src="<?php echo getUserImage($c_value["user_id"]); ?>" alt="<?php echo $full_name; ?>" />
                                    </a>
                                    <div class="content fl">
                                        <p class="name"><span class="blu"><a href="#" class="link_to_click" data-path="$(this).parent().parent().parent().prev();"><strong><?php echo $full_name; ?></strong></a></span>, <span class="time"><?php echo $time_ago; ?></span></p>
                                        <p><?php echo $message; ?></p>
                                    </div>
                                    <div class="cf"></div>
                                </li>
                                <?php
                            }

                            echo $this->getHelper('Event')->getChatPopup($chatUserArr);
                        }
                    ?>
                </ul>
                <div class="comment-box">
                    <form id="chat-form" method="post" action="<?php echo $this->baseUrl("ajax/eventchatsave"); ?>" >
                        <input class="commbox" id="chat-message" rel="<?php echo $last_chat_id; ?>" value="Write a comment ..." title="Write a comment ..." onblur="if (this.value == '') {
                                        this.value = this.title;
                                        this.style.fontStyle = 'italic';
                                    }" onfocus="if (this.value == this.title)
                                        this.value = '';
                                    this.style.fontStyle = 'normal';" style="font-style: italic;"/>
                    </form>
                </div>
            </div>
            <div class="cf"></div>
            <?php
                echo $this->partial("ads.phtml", array("ads_count" => "2"));
            ?>
        </div>
        <div class="cf"></div>
    </div>
</div>


<?php
    $host_details = $this->hostDetails;
//    prd($host_details);
    $host_id = $host_details["user_id"];
    $host_image = getUserImage($host_id);
    $host_full_name = $host_details["user_first_name"] . " " . $host_details["user_last_name"];
    $host_education = $host_details["user_education"];
    $host_from = $host_details["user_location"];
    $host_work = $host_details["user_work"];
    $host_gender = $host_details["user_gender"];
    if ($host_gender == "f")
        $host_gender = "Female";
    else
        $host_gender = "Male";
?>

<?php
//    if (empty($y))
//    {

    if ($this->isUsersOwnEvent == "no")
    {
        ?>
        <div class="alert-message show-profile" id="host-profile">
            <div class="am-wrapper">
                <a href="#close" class="close-button"></a>
                <div class="title">
                    <?php echo $host_details["user_first_name"]; ?> <strong><?php echo $host_details["user_last_name"]; ?></strong>
                </div>
                <div class="ginfos">
                    <div class="fr">
                        <img src="<?php echo $host_image; ?>" alt="<?php echo $host_full_name; ?>" />
                    </div>
                    <div class="fr sum">
                        <p>Education: <span class="v"><?php echo $host_education; ?></span></p>
                        <p>Work: <span class="v"><?php echo $host_work; ?></span></p>
                        <!--<p>Experience: <span class="v">12 years</span></p>-->
                        <?php
                        if (!empty($y))
                        {
                            ?>
                            <div class="add-friends">
                                <a href="javascript:;" class="rbox select bluebutton2 fr">
                                    <?php
                                    $add_to_another_group = 'no';
                                    //echo $friend_id;
//                            if ($this->isLoggedIn == 'yes' && !in_array($friend_id, $this->frndArr))

                                    if ($this->isLoggedIn == 'yes')
                                    {
                                        $add_to_another_group = 'yes';
                                        ?>    
                                        <span class="txt">Add to another group</span><span class = "arrow"></span>
                                        <?php
                                    }
                                    ?>    
                                    <ul class="dropdown">
                                        <?php
                                        foreach ($this->friendGroupsAndFriends as $gKey => $gValue)
                                        {
                                            if ($add_to_another_group == 'yes' && (in_array_custom($host_id, $gValue['friends_records'], 'user_id') ))
                                                continue;
                                            ?>    
                                            <li class="first" onclick="addFriend('<?php echo getEncryptedString($host_id); ?>', '<?php echo $gValue['group_id']; ?>', this);"><?php echo $gValue['group_name']; ?> <span>(<?php echo count($gValue['friends_records']); ?>)</span></li>
                                            <?php
                                        }
                                        ?>
                                        <li class="n">

                                        </li>
                                        <li class="n">

                                        </li>
                                        <?php
//                                    if ($add_to_another_group != 'yes')
//                                    {
                                        ?>
                                        <li class="c">
                                            Create Group
                                        </li>
                                        <?php
//                                    }
                                        ?>    
                                    </ul>
                                </a>
                            </div>
                            <?php
                        }
                        ?>
                    </div>
                    <div class="cf"></div>
                </div>
                <ul class="tabs tab-menu">
                    <li class="active"><a href="#personal-info">Personal info</a></li>
                    <li><a href="#rate-comment">Rates & comments</a></li>
                    <li><a href="#cevent-tab">Created events</a></li>
                    <?php
                    if (!empty($y))
                        echo '<li class="send-im"><a href="#im-tab">IM</a></li>';
                    ?>
                </ul>
                <div class="cf"></div>
                <div class="tabs-content">
                    <div class="tcontent personal-info active" id="personal-info">
                        <div class="pileft fl">
                            <p>Username: <strong><?php echo $host_details["user_username"]; ?></strong></p>
                            <p>Date of birth: <strong><?php echo date("d F Y", strtotime($host_details["user_dob"])); ?></strong></p>
                            <p>From: <strong><?php echo $host_from; ?></strong></p>
                            <p>Gender: <strong><?php echo $host_gender; ?></strong></p>
                            <p><br /></p>
                            <p>Published Events: <strong class="blu"><?php echo $host_details["published"]; ?></strong></p>
                            <p>Private: <strong class="blu"><?php echo $host_details["private"]; ?></strong></p>
                            <p>Public: <strong class="blu"><?php echo $host_details["public"]; ?></strong></p>
                            <p><br /></p>
                            <p>Attended Events: <strong class="org"><?php echo $host_details["attended"]; ?></strong></p>
                        </div>
                        <div class="pi-right fr">
                            <p>Overall <strong>Rating</strong></p>
                            <!--<span class="rate-star fr" rel="9"></span>-->
                            <?php
                            $yellow_star_count = $host_details["host_rating"];
                            $grey_start_count = RATING_STARS_MAX - $host_details["host_rating"];
                            ?>
                            <ul class="profile-stars">
                                <?php
                                for ($yellow_i = $yellow_star_count; $yellow_i >= "1"; $yellow_i--)
                                {
                                    echo '<li><img src="' . IMAGES_PATH . '/star-yellow.png" alt="stars"/></li>';
                                }
                                for ($grey_i = "1"; $grey_i <= $grey_start_count; $grey_i++)
                                {
                                    echo '<li><img src="' . IMAGES_PATH . '/star-grey.png" alt="stars"/></li>';
                                }
                                ?>
                            </ul>
                            <div class="cf"></div>
                            <p class="note ralign"><?php echo $host_details["host_rating"] . "/" . RATING_STARS_MAX; ?> Average rating</p>
                            <p><br /></p>
                            <p><a href="<?php echo getFacebookUsernameUrl($host_details["facebook_username"]); ?>" target="_blank" class="blu social-icon f"><?php echo $host_details["facebook_username"]; ?></a></p>
                            <p><a href="<?php echo getTwitterUsernameUrl($host_details["twitter_username"]); ?>" target="_blank" class="blu social-icon t"><?php echo $host_details["twitter_username"]; ?></a></p>
                            <p><a href="<?php echo getLinkedinUsernameUrl($host_details["linkedin_username"]); ?>" target="_blank" class="blu social-icon l"><?php echo $host_details["linkedin_username"]; ?></a></p>
                        </div>
                        <div class="cf"></div>
                        <p><br /></p>
                        <div class="line-ob"><span>About <strong>Me</strong></span></div>
                        <p class="v">Info:</p>
                        <p><br /></p>
                        <p class="fi"><?php echo $host_details["user_bio"]; ?></p>

                        <div class="line"></div>

                        <?php
                        if (!empty($y))
                        {
                            ?>
                            <div>
                                <a href="#" class="rbox sfebutton inv-button select">
                                    <span class="txt"><strong>Invite me</strong><br /><span>to your event</span></span>
                                    <span class="arrow"></span>
                                    <ul class="dropdown">
                                        <?php
                                        $setAppPlugin = new Application_Plugin_SetApp();
                                        $model = new Application_Model_Common();
//                                        prd($this->myEvents);
                                        if ($this->myEvents && !empty($this->myEvents))
                                        {

                                            $event_count = count($this->myEvents);
                                            $i = "1";

                                            foreach ($this->myEvents as $me_key => $me_value)
                                            {
                                                $event_id = $me_value["event_id"];
//                                                pr($event_id);
                                                $enc_event_id = getEncryptedString($event_id);
                                                $event_images = getEventImages($event_id);
                                                $event_title = $me_value["event_title"];
                                                $event_info = stripslashes($me_value["event_info"]);

                                                $class_name = "";
                                                if ($i == $event_count)
                                                {
                                                    $class_name = "last";
                                                }

//                                            if (!$setAppPlugin->checkIfEventAccepted($this->user['user_id'], $event_id))
//                                            {
                                                ?>
                                                <li class="<?php echo $class_name; ?>">
                                                    <img src="<?php echo $event_images[0]; ?>" alt="<?php echo $event_title; ?>" class="fl" />
                                                    <div class="details fl">
                                                        <div><p><?php echo $event_info; ?></p></div>
                                                    </div>
                                                    <div class="fl chk inviteToEventHost">
                                                        <!--<input type="checkbox" />-->
                                                        <?php
                                                        $ifEventJoined = $setAppPlugin->checkIfEventJoined($host_id, $event_id);
                                                        if ($ifEventJoined)
                                                        {
                                                            $shareClassName = "uncheck";
                                                            $shareText = "Shared";
                                                        }
                                                        else
                                                        {
                                                            $shareClassName = "bookmark";
                                                            $shareText = "Share event";
                                                        }
                                                        ?>
                                                        <button class="<?php echo $shareClassName; ?>" rel="<?php echo $enc_event_id; ?>" id="<?php echo $host_id; ?>"><?php echo $shareText; ?></button>
                                                    </div>
                                                    <div class="cf"></div>
                                                </li>
                                                <?php
                                                $i++;
//                                            }
                                            }
                                        }
                                        else
                                        {
                                            echo '<li class="last">No created events to display</li>';
                                        }
                                        ?>
                                    </ul>
                                </a>
                            </div>
                            <?php
                        }
                        ?>

                    </div>
                    <div class="tcontent rate-comment" id="rate-comment">
                        <div class="fl">
                            <p>Overall <strong>Rating</strong></p>
                            <!--<span class="rate-star fl" rel="9"></span>-->      
                            <?php
                            $yellow_star_count = $this->hostTotalRating;
                            $grey_start_count = RATING_STARS_MAX - $yellow_star_count;
                            ?>
                            <ul class="profile-stars">
                                <?php
                                for ($yellow_i = $yellow_star_count; $yellow_i >= "1"; $yellow_i--)
                                {
                                    echo '<li><img src="' . IMAGES_PATH . '/star-yellow.png" alt="stars"/></li>';
                                }
                                for ($grey_i = "1"; $grey_i <= $grey_start_count; $grey_i++)
                                {
                                    echo '<li><img src="' . IMAGES_PATH . '/star-grey.png" alt="stars"/></li>';
                                }
                                ?>
                            </ul>
                            <div class="cf"></div>
                            <p class="note"><?php echo $this->hostTotalRating . "/" . RATING_STARS_MAX; ?> Average rating</p>
                        </div>
                        <div class="cf"></div>
                        <div class="line"></div>
                        <div class="comments-list">
                            <?php
                            if (!empty($this->hostOtherUsersComments))
                            {
                                foreach ($this->hostOtherUsersComments as $o_key => $o_value)
                                {
                                    $friend_id = $o_value["user_id"];
                                    $friend_image = getUserImage($friend_id);
                                    $friend_full_name = $o_value["user_first_name"] . " " . $o_value["user_last_name"];
                                    $event_title = $o_value["event_title"];
                                    $comment = $o_value["ecm_comment"];
                                    $posted_on = date("d F Y", strtotime($o_value["ecm_timestamp"]));
                                    $stars_rated = $o_value["ecm_ratings"];
                                    $yellow_star_count = $stars_rated;
                                    $grey_start_count = RATING_STARS_MAX - $yellow_star_count;
                                $event_link = $this->baseUrl("eventdetail/" . getEncryptedString($o_value["ecvm_event_id"]));
                                    ?>
                                    <div class="comm">
                                        <div class="avt fl">
                                            <img src="<?php echo $friend_image; ?>" alt="<?php echo $friend_full_name; ?>" />
                                        </div>
                                        <div class="details fl">
                                            <div class="fl dl" style="width: 100%;">
                                                <p class="fl" style="max-width: 178px;">
                                                <!--<span class="title"><a href="#"><?php echo $friend_full_name; ?></a></span>--> 
                                                    <span class="title"><?php echo $friend_full_name; ?>,</span> 
                                                    <a href="<?php echo $event_link;?>" class="tlink blu"><?php echo $event_title; ?></a>
                                                </p>

                                                <ul class="profile-stars" style="float: right;">
                                                    <?php
                                                    for ($yellow_i = $yellow_star_count; $yellow_i >= "1"; $yellow_i--)
                                                    {
                                                        echo '<li><img src="' . IMAGES_PATH . '/star-yellow.png" alt="stars"/></li>';
                                                    }
                                                    for ($grey_i = "1"; $grey_i <= $grey_start_count; $grey_i++)
                                                    {
                                                        echo '<li><img src="' . IMAGES_PATH . '/star-grey.png" alt="stars"/></li>';
                                                    }
                                                    ?>
                                                </ul>
                                                <div class="cf"></div>
                                                <p class="txt"><?php echo $comment; ?></p>
                                                <p class="time">Posted on <span class="blu"><?php echo $posted_on; ?></span></p>
                                            </div>
                                        </div>
                                        <div class="cf"></div>
                                    </div>
                                    <?php
                                }
                            }
                            else
                            {
                                echo '<h3>No ratings yet</h3>';
                            }
                            ?>
                        </div>
                    </div>
                    <div class="tcontent cevent-tab" id="cevent-tab">
                        <div class="events-list">
                            <?php
                            $all_event_i = "1";
                            foreach ($this->hostCreatedEvents as $fr_key => $fr_value)
                            {
                                if (!empty($fr_value))
                                {
                                    $event_id = $fr_value["event_id"];
                                        $event_link = $this->baseUrl("eventdetail/" . getEncryptedString($event_id));
                                    $event_title = stripslashes($fr_value["event_title"]);
                                    $title_length = strlen($event_title);
                                    if ($title_length > 30)
                                    {
                                        $event_title = substr($event_title, 0, 30) . "...";
                                    }
//                            $event_time = date("H:m", strtotime($fr_value["event_time"])) . " " . TIME_ZONE;
                                    $event_time = date("g:i a", strtotime($fr_value["event_time"]));
                                    $event_type = ucwords($fr_value["event_type"]);
                                    $event_group_size = $fr_value["event_group_size"];
                                    if (empty($event_group_size))
                                        $event_group_size = "NA";

                                    $event_date_array = json_decode($fr_value["event_date"]);
                                    $event_date = $event_date_array->day[0] . " " . date("F", strtotime($event_date_array->month[0])) . " " . $event_date_array->year[0];

                                    $event_address = stripslashes(trim($fr_value["event_address"] . ", " . $fr_value["event_location"]));
                                    $event_info = stripslashes(($fr_value["event_info"]));

                                    $category_id = $fr_value["category_id"];
                                    $category_name = $fr_value["category_name"];
                                    $subcategory_id = $fr_value["subcategory_id"];
                                    $subcategory_name = $fr_value["subcategory_name"];
                                    $creator_full_name = $fr_value["user_first_name"] . " " . $fr_value["user_last_name"];
                                    if ($creator_full_name == " ")
                                        $creator_full_name = "NA";

                                    $first_post_class = "";
                                    if ($all_event_i == "1")
                                        $first_post_class = " first";

                                    $event_images = getEventImages($event_id);
                                    $event_link = $this->baseUrl("eventdetail/" . getEncryptedString($event_id));
                                    ?>
                                    <div class="event">
                                        <div class="ewrap">
                                            <div class="pimg fl">
                                                <img src="<?php echo $event_images[0]; ?>" alt="<?php echo $event_title; ?>">
                                            </div>
                                            <div class="details fl">
                                                <div class="e-title">
                                                    <a class="p-name tlink" href="<?php echo $event_link; ?>"><?php echo $event_title; ?></a>
                                                    <span class="p-cates">
                                                        <span>in </span><a class="org tlink" href="<?php echo $this->baseUrl("event/search?cat_search=$category_id"); ?>"><?php echo $category_name; ?></a> / <a class="org tlink" href="<?php echo $this->baseUrl("event/search?subcat_search=$subcategory_id"); ?>"><?php echo $subcategory_name; ?></a>
                                                    </span>
                                                    <span class="p-time"><?php echo $event_date . " / " . $event_time; ?></span>
                                                </div>
                                                <div class="infos">
                                                    <span class="group">Group size</span><span><?php echo $event_group_size; ?></span>
                                                    <span>/</span><span class="org">Address</span><span><?php echo $event_address; ?></span>
                                                    <span class="publish fr blu"><a href="#"><?php echo $event_type; ?></a></span>
                                                    <div class="cf"></div>
                                                    <div class="desc fl">
                                                        <?php echo $event_info; ?>
                                                    </div>
                                                    <div class="fr view">
                                                        <a class="rbox bluebutton2" href="<?php echo $event_link; ?>"><strong>View</strong></a>
                                                    </div>
                                                    <div class="cf"></div>
                                                </div>
                                            </div>
                                            <div class="cf"></div>
                                        </div>
                                    </div>
                                    <?php
                                    $all_event_i++;
                                }
                                else
                                {
                                    echo '<h3>No created events<h3>';
                                    break;
                                }
                            }
                            ?>
                        </div>
                    </div>
                    <?php
                    if (!empty($y))
                    {
                        ?>
                        <div class="tcontent im-tab" id="im-tab">
                            <h1 class="im-title">Your <span class="blu">IM</span></h1>
                            <form id="im-form" method="post" name="profileComment" id="profileComment" onsubmit="return validateForm('reply', this)" >
                                <p><textarea maxlength="1000" name="commbox" class="radius area commbox" onfocus="this.style.borderColor = '#1996d4'" onblur="this.style.borderColor = '#cfcfcf'" style="border-color: rgb(207, 207, 207);"></textarea></p>
                                <p class="note">1000 characters max</p>
                                <p><br /></p>
                                <div class="fl">
                                    <!--<a href="#" class="bluefbutton fl"><strong>Send IM</strong></a>-->
                                    <input type="hidden" class="message_to"  value="<?php echo $host_id; ?>" name="message_to">
                                    <input type="submit" class="bluefbutton fl" name="sbmt" value="Send IM"/>
                                </div>
                            </form>
                            <div class="fr pass-message"><a href="<?php echo $this->baseUrl("message"); ?>" class="org tlink">View Past messages with <?php echo $host_full_name; ?></a></div>
                            <div class="cf"></div>
                        </div>
                        <?php
                    }
                    ?>
                </div>
            </div>
        </div>
        <?php
    }
//    }
?>

<?php
    if ($this->isLoggedIn == 'no' || $this->isUsersOwnEvent == 'no')
        $this->getHelper('Event')->init($this->event_id, 'attending');
    else
        $this->getHelper('Event')->init($this->event_id);
?>

<script>
                                $(document).ready(function() {
                                    $("#check-distance").click(function(event) {
                                        event.preventDefault();
                                        var another_address = $("#another_address").val();
                                        if (another_address != "")
                                        {
                                            $("#distance-here").html("Wait...");
                                            var event_address = "<?php echo $event_full_address; ?>";
                                            $.ajax({
                                                type: "POST",
                                                url: "<?php echo $this->baseUrl("ajax/geteventdistance"); ?>",
                                                data: {"another_address": another_address, "event_address": event_address},
                                                success: function(response) {
                                                    $("#distance-here").html(response);
                                                }
                                            });
                                        }
                                    });
                                    //console.log($("a#event-join"));   
                                    $("a#event-join").live("click", function(event) {
                                        //alert("sdf");
                                        event.preventDefault();
                                        $(".please-wait").show();
                                        window.location.href = "<?php echo $this->baseUrl("event/joinevent?enc_event_id=" . getEncryptedString($this->event_id)); ?>";
                                    });

                                    $("a#event-leave").live("click", function(event) {
                                        event.preventDefault();
                                        $(".please-wait").show();
                                        window.location.href = "<?php echo $this->baseUrl("event/leaveevent?enc_event_id=" . getEncryptedString($this->event_id)); ?>";
                                    });

                                    $(".social-share .ssleft .bookmark").live("click", function() {
                                        var event_id = "<?php echo getEncryptedString($this->event_id); ?>";
                                        $.ajax({
                                            type: "POST",
                                            url: "<?php echo $this->baseUrl("ajax/bookmarkevent"); ?>",
                                            data: {"event_id": event_id},
                                            success: function(response) {
                                                //                                                if (response == "1")
                                                //                                                {
                                                //                                                $(".bookmark").addClass("uncheck");
                                                //                                                $(".uncheck").removeClass("bookmark");
                                                //                                                $(".uncheck").html("Uncheck");
                                                //                                            }
                                            }
                                        });
                                    });

                                    $(".social-share .ssleft .uncheck").live("click", function(event) {
                                        event.preventDefault();
                                        var event_id = "<?php echo getEncryptedString($this->event_id); ?>";
                                        $.ajax({
                                            type: "POST",
                                            url: "<?php echo $this->baseUrl("ajax/bookmarkevent"); ?>",
                                            data: {"event_id": event_id},
                                            success: function(response) {
                                                //                                                if (response == "1")
                                                //                                                {
                                                $(this).addClass("bookmark");
                                                $(this).removeClass("uncheck");
                                                $(this).html("Bookmark");
                                                //                                                }
                                            }
                                        });
                                    });

                                    $("#chat-message").click(function() {
                                        var isLoggedIn = "<?php echo $this->isLoggedIn; ?>";
                                        if (isLoggedIn == "no")
                                        {
                                            $('#login-button').click();
                                            return false;
                                        }
                                    });

                                    $("#chat-form").submit(function(event) {
                                        var isLoggedIn = "<?php echo $this->isLoggedIn; ?>";
                                        if (isLoggedIn == "no")
                                        {
                                            $('#login-button').click();
                                            return false;
                                        }

                                        event.preventDefault();
                                        var url = $("#chat-form").attr("action");
                                        var user_id = "<?php echo getEncryptedString($this->logged_user_id) ?>";
                                        var event_id = "<?php echo getEncryptedString($this->event_id); ?>";
                                        var message = $("#chat-message").val();
                                        $("#chat-message").val("");
                                        $.ajax({
                                            type: "POST",
                                            url: url,
                                            dataType: "json",
                                            data: {"event_id": event_id, "user_id": user_id, "message": message},
                                            success: function(response) {
                                                $(".chat-box ul").append(response.chat);
                                                $("#chat-message").attr("rel", response.last_event_id);
                                                //console.log(response.last_event_id);
                                                scrollTOBottom();
                                            }
                                        });
                                    });

                                    setInterval(ajaxchat, 5000);
                                    function ajaxchat()
                                    {
                                        $.ajax({
                                            async: true,
                                            type: "POST",
                                            url: "<?php echo $this->baseUrl("ajax/getajaxeventchat"); ?>",
                                            dataType: "json",
                                            data: {"last_event_id": $("#chat-message").attr("rel"), "event_id": "<?php echo getEncryptedString($this->event_id); ?>"},
                                            success: function(response) {
                                                if (response.chat != "")
                                                {
                                                    $(".chat-box ul").append(response.chat);
                                                    $("#chat-message").attr("rel", response.last_event_id);
                                                    scrollTOBottom();
                                                    if (response.chatPopup) {
                                                        $('.show-profile-test').lytebox({showClose: false, closeButton: $($('.show-profile-test').attr('href')).find('.close-button')});
                                                    }
                                                }
                                            }
                                        });
                                    }


                                    function OpenInNewTab(url)
                                    {
                                        var win = window.open(url, '_blank');
                                        win.focus();
                                    }

                                    $(".bannerImg").click(function(event) {
                                        event.preventDefault();
                                        var rel = $(this).attr("rel");
                                        var imagePath = $(this).attr("href");

                                        if (rel == "image")
                                        {
                                            $("#toPlayVideo").html('<img class="main-img fl" alt="main img" src="' + imagePath + '" />');
                                        }
                                        else
                                        {
                                            $("#toPlayVideo").html('<iframe class="main-img fl" width="421" height="237" src="' + imagePath + '"  frameborder="0" allowfullscreen></iframe>');
                                        }
                                    });

                                    $(".inviteToEventHost .bookmark").live("click", function(event) {
                                        event.preventDefault();
                                        var user_id = $(this).attr("id");
                                        var event_id = $(this).attr("rel");
                                        var url = "<?php echo $this->baseUrl("ajax/eventinvite?event_id="); ?>" + event_id + "&user_id=" + user_id;
                                        $.ajax({
                                            url: url
                                        });
                                        $(this).addClass("uncheck");
                                        $(this).removeClass("bookmark");
                                        $(this).html("Shared");
                                    });

                                    $(".inviteToEventHost .uncheck").live("click", function(event) {
                                        event.preventDefault();
                                        var event_id = $(this).attr("rel");
                                        var user_id = $(this).attr("id");
                                        $.ajax({
                                            type: "POST",
                                            url: "<?php echo $this->baseUrl("ajax/removesharedevent"); ?>",
                                            data: {"event_id": event_id, "user_id": user_id}
                                        });
                                        $(this).addClass("bookmark");
                                        $(this).removeClass("uncheck");
                                        $(this).html("Share event");
                                    });


                                    scrollTOBottom();


                                });
</script>
